Skip to content

Conversation

@Ngone51
Copy link
Member

@Ngone51 Ngone51 commented Feb 17, 2020

What changes were proposed in this pull request?

Prefix by ansi_ in toString if it's a AnsiCast or ansi enabled Cast.

E.g. run spark.sql("select cast('51' as int)").queryExecution.analyzed under ansi mode.

Before this PR:

Project [cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation

After this PR:

Project [ansi_cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation

Why are the changes needed?

This is useful while comparing LogicalPlans literally.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Pass Jenkins.

@Ngone51
Copy link
Member Author

Ngone51 commented Feb 17, 2020

cc @cloud-fan @gengliangwang


override def toString: String = s"cast($child as ${dataType.simpleString})"
override def toString: String = {
val ansi = if (ansiEnabled) "ansi" else ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ansi_?

@SparkQA
Copy link

SparkQA commented Feb 17, 2020

Test build #118592 has finished for PR 27608 at commit e550b87.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Feb 17, 2020

Test build #118588 has finished for PR 27608 at commit 92a899f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member

maropu commented Feb 17, 2020

For better commit logs, could you put a simple example plan output before/after this pr in the description above?

@Ngone51
Copy link
Member Author

Ngone51 commented Feb 18, 2020

For better commit logs, could you put a simple example plan output before/after this pr in the description above?

Added. Thanks!

@cloud-fan
Copy link
Contributor

@Ngone51 can we have a JIRA? It touches many files and worth a JIRA.

@Ngone51 Ngone51 changed the title [MINOR][SQL] Distinguish Cast and AnsiCast in toString [SPARK-30863][SQL] Distinguish Cast and AnsiCast in toString Feb 18, 2020
@Ngone51
Copy link
Member Author

Ngone51 commented Feb 18, 2020

@Ngone51 can we have a JIRA? It touches many files and worth a JIRA.

Done.

@SparkQA
Copy link

SparkQA commented Feb 18, 2020

Test build #118607 has finished for PR 27608 at commit 4896fb5.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.


override def toString: String = s"cast($child as ${dataType.simpleString})"
override def toString: String = {
val ansi = if (ansiEnabled) "ansi_" else ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be "ansiCast" or "ANSICast" instead of "ansi_cast"

Copy link
Contributor

@cloud-fan cloud-fan Feb 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows the existing SQL function naming convention, e.g. FromUTCTimestamp.prettyName is from_utc_timestamp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the string of newInstance is newInstance($cls) ..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NewInstance is not really a SQL function/operator...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. It is the first expression the overrides toString with 2 words in IDE...haha

@cloud-fan
Copy link
Contributor

thanks, merging to master/3.0!

@cloud-fan cloud-fan closed this in 643a480 Feb 18, 2020
@Ngone51
Copy link
Member Author

Ngone51 commented Feb 18, 2020

Thanks all!!

cloud-fan pushed a commit that referenced this pull request Feb 18, 2020
### What changes were proposed in this pull request?

Prefix by `ansi_`  in `toString` if it's a `AnsiCast` or ansi enabled `Cast`.

E.g. run `spark.sql("select cast('51' as int)").queryExecution.analyzed` under ansi mode.

Before this PR:
```
Project [cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```

After this PR:
```
Project [ansi_cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```

### Why are the changes needed?

This is useful while comparing `LogicalPlan`s literally.

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Pass Jenkins.

Closes #27608 from Ngone51/ansi_cast_tostring.

Authored-by: yi.wu <yi.wu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit 643a480)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
sjincho pushed a commit to sjincho/spark that referenced this pull request Apr 15, 2020
### What changes were proposed in this pull request?

Prefix by `ansi_`  in `toString` if it's a `AnsiCast` or ansi enabled `Cast`.

E.g. run `spark.sql("select cast('51' as int)").queryExecution.analyzed` under ansi mode.

Before this PR:
```
Project [cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```

After this PR:
```
Project [ansi_cast(51 as int) AS CAST(51 AS INT)#0]
+- OneRowRelation
```

### Why are the changes needed?

This is useful while comparing `LogicalPlan`s literally.

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Pass Jenkins.

Closes apache#27608 from Ngone51/ansi_cast_tostring.

Authored-by: yi.wu <yi.wu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
gengliangwang added a commit that referenced this pull request Feb 18, 2022
…st" under ANSI mode

### What changes were proposed in this pull request?

Change Cast.toString as "cast" instead of "ansi_cast" under ANSI mode.
This is to restore the behavior before #27608

### Why are the changes needed?

1. There is no such a function "ansi_cast" in Spark SQL
2. Add/Divide/.. has different behavior under ANSI mode as well, but they don't have this special string representation.
3. As we are setting up new Github job for ANSI mode, this can avoid test failures from TPCDS plan stability test suites

### Does this PR introduce _any_ user-facing change?

Yes but quite minor, the string output of `Cast` under ANSI mode becomes "cast" instead of "ansi_cast" again.

### How was this patch tested?

Existing UT

Closes #35570 from gengliangwang/revert-SPARK-30863.

Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants